package com.sf.novatar.sample.redis;

import com.sf.iisp.kafka.adapter.IKafkaProducerPoolDelegate;
import com.sf.iisp.util.DateUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.Date;
import java.util.UUID;

/**
 * Created by qi on 16-7-14.
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/beans.xml"})
public class KafkaTestCase {

    @Autowired
    private IKafkaProducerPoolDelegate delegate;

    @Test
    public void testSendKafka() {

        String uuid = UUID.randomUUID().toString();
        System.out.println("uuid = " + uuid);
        String strDate = DateUtils.date2Str(new Date(), DateUtils.datetimeFormat);
        System.out.println("binding date = " + strDate);
        String content = "{\"courierPhone\":\"15012905286\",\"customerPhone\":\"18675523334\",\"extendField1\":\"002AAABVYGDxe8feo6mDdZHYKeIwxX5Npzf\",\"msgType\":\"iisp.telephone.bind\",\"sysCode\":\"SGS\",\"transId\":\"" + uuid + "\",\"transTimestamp\":\"" + strDate + "\"}";
        String content1 = "{\"courierPhone\":\"15914085476\",\"customerPhone\":\"18675523334\",\"extendField1\":\"002AAABVYGDxe8feo6mDdZHYKeIwxX5Npzf\",\"msgType\":\"iisp.telephone.unbind\",\"sysCode\":\"SGS\",\"transId\":\"" + uuid + "\",\"transTimestamp\":\"" + strDate + "\"}";

        //涅槃解绑　　transId 2b5b6afc-db9a-4867-8b90-2857a79ae5d9
        String content2 = "{\"courierPhone\":\"15112905286\",\"customerPhone\":\"18675523334\",\"extendField1\":\"002AAABVYGDxe8feo6mDdZHYKeIwxX5Npzf\",\"msgType\":\"iisp.telephone.unbind\",\"sysCode\":\"SGS\",\"transId\":\"" + uuid + "\",\"transTimestamp\":\"" + strDate + "\"}";
        String reverContent = "{\n" +
                "  \"courierPhone\": \"15012905286\",\n" +
                "  \"customerPhone\": \"18675523334\",\n" +
                "  \"reservedTime\": \"0\",\n" +
                "  \"extendField1\": \"002AAABVYGDxe8feo6mDdZHYKeIwxX5Npzf\",\n" +
                "  \"msgType\": \"iisp.telephone.bind\",\n" +
                "  \"sysCode\": \"IISPG\",\n" +
                "  \"transId\": \"" + uuid + "\", \n" +
                "  \"transTimestamp\": \"" + strDate + "\"\n" +
                "}";
        String reverUnContent = "{\n" +
                "  \"courierPhone\": \"15112905286\",\n" +
                "  \"customerPhone\": \"18675523334\",\n" +
                "  \"reservedTime\": \"2016-07-21 21:15:00\",\n" +
                "  \"extendField1\": \"002AAABVYGDxe8feo6mDdZHYKeIwxX5Npzf\",\n" +
                "  \"msgType\": \"iisp.telephone.unbind\",\n" +
                "  \"sysCode\": \"IISPG\",\n" +
                "  \"transId\": \"" + uuid + "\", \n" +
                "  \"transTimestamp\": \"" + strDate + "\"\n" +
                "}";
        delegate.sendString(reverContent);
//        delegate.sendString("{\n" +
//                "\t\"transId\":\"test00000000001\",\n" +
//                "\t\"transTimestamp\": \""+ DateFormatUtils.format(new Date(), "yyyy-MM-dd HH:mm:ss")+"\",\n" +
//                "\t\"msgType\" : \"iisp.telephone.unbind\",\n" +
//                "\t\"sysCode\" : \"IISP\",\n" +
//                "\t\"courierPhone\" : \"13888888888\",\n" +
//                "\t\"customerPhone\" : \"18611123334\",\n" +
//                "\t\"reservedTime\": \"0\",\n" +
//                "\t\"invalidTime\" : \"0\",\n" +
//                "\t\"extendField1\" : \"extendField1\",\n" +
//                "\t\"extendField2\" : \"extendField2\"\n" +
//                //"\t\"extendField1\" : \"xxxxxx\",\n" +
//              //  "\t\"extendField2\" : \"yyyyyy\"\n" +
//                "}");
    }
}
